#ifndef _Ape__Uuid_h
#define _Ape__Uuid_h

#include <Ape/Object.h>

namespace Ape {
	class String;
	class ULong;
	/**
		xxxx xxxx - xxxx - xxxx - xxxx - xxxx xxxx xxxx
		4b - 2b - 2b - 2b - 6b
		
		@author Roman Gafiyatullin
	*/
	class Uuid : public Object {
		TYPE_NAME ("Ape::Uuid")
		friend bool operator == (const Uuid& u1, const Uuid& u2);
		friend bool operator <  (const Uuid& u1, const Uuid& u2);
		friend bool operator >  (const Uuid& u1, const Uuid& u2);
	private:
	
		char m_1[4];
		char m_2[2];
		char m_3[2];
		char m_4[2];
		char m_5[6];
		
		static void PutBuffIntoContainer (char* container, const char* buff, size_t length);
		
		//static ULong Container2Long(const char* container, size_t buffSize);
		static String Container2String (const char* container, size_t size);
	public:
		Uuid();
		Uuid (const Uuid& other);
		Uuid (const String& s);
		Uuid (const char bytes[16]);
		
		virtual ~Uuid();
		
		void Reset();
		
		virtual void _Dump (bool verbose = false) const;
		virtual const String ToString() const;
		
		static Uuid Generate();
	};
	
	bool operator == (const Uuid& u1, const Uuid& u2);
	bool operator != (const Uuid& u1, const Uuid& u2);
	bool operator <  (const Uuid& u1, const Uuid& u2);
	bool operator >  (const Uuid& u1, const Uuid& u2);
	bool operator <= (const Uuid& u1, const Uuid& u2);
	bool operator >= (const Uuid& u1, const Uuid& u2);
}

#endif // _Ape__Uuid_h
